﻿# CMakeList.txt: libevent_openssl_test 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required(VERSION 3.10)
project(libevent_openssl_test)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if(DEFINED ENV{VCPKG_ROOT})
    set(CMAKE_TOOLCHAIN_FILE "D:/vcpkg_test_ssl_libevent/vcpkg/scripts/buildsystems/vcpkg.cmake")
else()
    message(FATAL_ERROR "Please set VCPKG_ROOT environment variable to vcpkg root directory")
endif()

file(GLOB MESSAGE_SRC ./message/*.h ./message/*/*.h)


find_package(libevent REQUIRED)

add_executable(server server.cpp ${MESSAGE_SRC})
#add_executable(client client.cpp ${MESSAGE_SRC})
target_link_libraries(server PRIVATE libevent::core libevent::extra libevent::openssl)
#target_link_libraries(client PRIVATE libevent::core libevent::extra libevent::openssl)


#add_executable(server_nossl "no_ssl_test/server_nossl.cpp")
#add_executable(client_nossl "no_ssl_test/client_nossl.cpp")
#target_link_libraries(server_nossl PRIVATE libevent::core libevent::extra libevent::openssl)
#target_link_libraries(client_nossl PRIVATE libevent::core libevent::extra libevent::openssl)
# 复制证书文件到可执行文件目录
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/certificate/client.crt
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/client.key
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/server.crt
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/server.key
     DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
